class linkNode {
    constructor(value = 0) {
        this.value = value
        this.next = null
    }
}
function linkMerge(l1, l2) {
    // if(!l1){
    //     return l2
    // }
    // if(!l2){
    //     return l1
    // }
    let l =new linkNode()
    let current = l
    while(l1&&l2){
        if(l1.value<l2.value){
            current.next = l1
            l1= l1.next
        }else{
            current.next = l2
            l2= l2.next
        }
        current = current.next
    }
    if(!l1){
        current.next = l2
    }
    if(!l2){
        current.next =l1
    }
    return l.next
}

let l1 = new linkNode(1)
l1.next = new linkNode(3)
l1.next.next = new linkNode(5)

let l2 = new linkNode(2)
l2.next = new linkNode(4)
l2.next.next = new linkNode(6)

const mergeLink = linkMerge(l1, l2)
let current = mergeLink
while(current){
    console.log(current.value)
    current= current.next
}